
class Armature(object):
    __slots__ = (
        "name",
        "context",
        "armature",
        "arm_data",
        "bones",
        "root_bones",
        )

    def __init__(self, armature, adj_mat):
        self.armature = armature
        self.name = armature.name
        self.arm_data = armature.data
        self.bones = {}
        self.root_bones = []

        for bone in self.arm_data.bones:
            if (not bone.name.startswith("IK_")):
                from ossl.types.Bone import Bone
                self.bones[bone.name] = Bone(self, bone.name, adj_mat)

        for bone in self.bones.values():
            bone.adjust_hierarchy_up(self)

        for bone in self.bones.values():
            if bone.parent == None:
                self.root_bones.append(bone)

        for bone in self.root_bones:
            bone.adjust_hierarchy_down(self)

############## MenuFolder ###############

import bpy, ossl.menu as menu

class OSSL_MT_Armature(menu.MenuFolder):
    bl_label = "OSSL Menu Armature"
    bl_idname = "OSSL_MT_Armature"

def OSSL_menu_Armature(self, comtext):
    self.layout.menu("OSSL_MT_Armature", text="Armature", icon="CON_ARMATURE")

import ossl.util as util

def register():
    print("registering: OSSL Type Armature")
    bpy.utils.register_class(OSSL_MT_Armature)
    bpy.types.TOPBAR_MT_OSSL.append(OSSL_menu_Armature)
    util.imports("ossl.types.Armature", "generate")
    print("registered: OSSL Type Armature")

def unregister():
    print("unregistering: OSSL Type Armature")
    util.release("ossl.types.Armature", "generate")
    bpy.types.TOPBAR_MT_OSSL.remove(OSSL_menu_Armature)
    bpy.utils.unregister_class(OSSL_MT_Armature)
    print("unregistered: OSSL Type Armature")

if __name__ == "__main__":
    util.reset_addon()
